package com.bc.web.model;

import com.bc.common.basemodel.BaseTransferQrcode;
import com.fs.common.extend.FSSearchCondition;
import com.fs.common.extend.FSSqlHelper;
import com.jfinal.plugin.activerecord.Page;

@SuppressWarnings("serial")
public class TransferQrcode extends BaseTransferQrcode<TransferQrcode> {
	
	public static final TransferQrcode dao = new TransferQrcode().dao();

	public Page<TransferQrcode> search(FSSearchCondition sc){
		int pageNumber = sc.page.getPageNum();
		int pageSize = sc.page.getNumPerPage();
		
		Double d = sc.get("amount") != null ? Double.parseDouble(sc.get("amount").toString()) * 100 : null;
		
		FSSqlHelper sql = new FSSqlHelper(" from transfer_qrcode WHERE 1 = 1");
		sql.equals("aliAccount", sc.get("aliAccount"));
		sql.equals("amount", d);
		sql.equals("remark", sc.get("remark"));
		sql.like("name", sc.get("name"));
		String createTimeStart = sc.getStr("createTimeStart");
		String createTimeEnd = sc.getStr("createTimeEnd");
		sql.date("createTime", createTimeStart, createTimeEnd);
		sql.orderBy("createTime", "desc");
		return super.paginate(pageNumber, pageSize, "select *", sql.toString(),sql.getParams());
	}
	
	public TransferQrcode selectByURL(String url){
		return super.findFirst("select * from transfer_qrcode where qrcodeUrl = ?", url);
	}
	
	public TransferQrcode selectQrcode() {
		return null;
	}
}
